<template>
    <div class="mycenter">
        <group>
            <cell title="头像" value="暂无" @click.native="onClick">
                <div class="myheadimg">
                    <img :src="FaceUrl" alt="">
                </div>
            </cell>
            <cell title="昵称" :value="NickName"></cell>
        </group>
        <group title="安全信息">
            <cell :is-link="mobile===''" title="手机认证" :value="mobile|getrzworld" @click.native="jumpphone"></cell>
            <cell :is-link="realityName===''" title="身份认证" @click.native="junpid"
                  :value="realityName===''?'立即认证':`(${realityName})${idcardNumber}`"></cell>
            <cell is-link title="银行卡认证" @click.native="jumpyhlist" :value="blanklists.length>0?'已绑定':'立即认证'"></cell>
        </group>
    </div>
</template>

<script>
    import {getMyInfoR, getBlankCardListsR} from '../../service/my';
    import {getMytoken} from '../../service/common';
    import {Cell, CellBox, CellFormPreview, Group, Badge} from 'vux';
    import store2 from 'store2';
    export default {
        components: {
            Cell, CellBox, CellFormPreview, Group, Badge
        },
        data() {
            return {
                mobile: '',
                idcardNumber: '',
                realityName: '',
                NickName: '',
                FaceUrl: '',
                blanklists: []
            };
        },
        created() {
            this.getinfp();
        },
        filters: {
            getrzworld(value){
                return value === '' ? '立即认证' : value;
            }
        },
        computed: {},
        methods: {
            async getinfp(){
                const {token}=await getMytoken();
                const {data}=await getMyInfoR(token);
                const {NickName, FaceUrl}=store2('userInfo');
                this.NickName = NickName;
                this.FaceUrl = FaceUrl;
                if(data && data.code === 0) {
                    const {clientMbr}=data.data;
                    this.mobile = clientMbr.mobile;
                    this.idcardNumber = clientMbr.idcardNumber;
                    this.realityName = clientMbr.realityName;
                }
                else {

                }
                this.getblankcardlist();
            },
            junpid(){
                if(this.realityName != '') {
                    return;
                }
                this.$router.push('/my/center/realname')
            },
            async getblankcardlist(){
                const {token}=await getMytoken();
                const {data}=await getBlankCardListsR({UserIDGuid: token});
                if(data && data.code === 0) {
                    this.blanklists = data.data;
                }
            },
            async jumpphone(){
                if(this.mobile != '') {
                    return;
                }
                this.$router.push('/my/center/phone')
            },
            jumpyhlist(){
                if(this.mobile != '' && this.realityName != '') {
                    this.$router.push('/my/center/blankcards')
                }
                else {
                    this.$vux.toast.text('请先完手机跟身份认证');
                }
            }
        }
    }
</script>
<style scoped lang="less" rel="stylesheet/less">
    @import "../app";

    .mycenter {
        height: 100%;
        display: flex;
        flex-direction: column;
        .myheadimg {
            img {
                width: 60px;
                height: 60px;
                display: block;
                border-radius: 50%;
            }
        }
    }
</style>